<?php
/**
 * Author: liujin
 * Date: 2022/1/9
 * Time: 10:13 下午
 * Describe:
 */
$retDays = [
    '01天' => 0,
    '02天' => 0,
    '03天' => 0,
    '04天' => 0,
    '05天' => 0,
    '06天' => 0,
    '07天' => 0,
    '08天' => 0,
    '09天' => 0,
    '10天' => 0,
    '11天' => 0,
    '12天' => 0,
    '13天' => 0,
    '14天' => 0,
    '16天' => 0,
    '17天' => 0,
    '18天' => 0,
    '19天' => 0,
    '20天' => 0,
    '21天' => 0,
    '22天' => 0,
    '23天' => 0,
    '24天' => 0,
    '25天' => 0,
    '26天' => 0,
    '27天' => 0,
    '28天' => 0,
    '29天' => 0,
    '30天' => 0,
    '31天' => 0,
];
$maxDay = 31;
$lastDay = 28;
$dayLength = $maxDay - $lastDay;
$a  = getDatesBetweenTwoDays('2022-01-02 00:00:00', '2022-01-07 24:00:00');
var_dump($a);die;
/**
 * 获取两个时间之间的日期
 * @param $startDate
 * @param $endDate
 * @return array
 */
function getDatesBetweenTwoDays($startDate, $endDate)
{
    $dates = [];
    if (strtotime($startDate) > strtotime($endDate)) {
        // 如果开始日期大于结束日期，直接return 防止下面的循环出现死循环
        return $dates;
    } elseif ($startDate == $endDate) {
        // 开始日期与结束日期是同一天时
        array_push($dates, $startDate);
        return $dates;
    } else {
        array_push($dates, $startDate);
        $currentDate = $startDate;
        do {
            $nextDate = date('Y-m-d', strtotime($currentDate . ' +1 days'));
            array_push($dates, $nextDate);
            $currentDate = $nextDate;
        } while ($endDate != $currentDate);

        return $dates;
    }
}
if ($dayLength) {
    for ($i = $maxDay; $i > $lastDay ; $i--) {
        $key = $i . '天';
        unset($retDays[$key]);
    }
}
var_dump($retDays);die;
echo date('d', strtotime(date('Y-m-t',strtotime ("09.13.1987"))));